# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Yaron de Leeuw <me@jarondl.net>

pkgbase=python-isort
pkgname=('python-isort' 'python2-isort')
pkgver=4.3.4
pkgrel=2
pkgdesc="A Python utility / library to sort Python imports."
arch=('any')
url="https://github.com/timothycrosley/isort"
license=('MIT')
makedepends=('python-setuptools' 'python2-setuptools' 'python2-futures')
checkdepends=('python-pytest' 'python2-pytest' 'python-mock' 'python2-mock')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/timothycrosley/isort/archive/$pkgver.tar.gz")
sha512sums=('cc9254c288e479a05cc20c29c9be6fa368a46e85f8eb0a22238ee3e57004a75999d35d2a736ad0a4ddc7d7c7efcc30fb97bfd16fcd0adb44d3b937dd935588b7')

prepare() {
  cp -a isort-$pkgver{,-py2}
}

build() {
  cd "$srcdir"/isort-$pkgver
  python setup.py build

  cd "$srcdir"/isort-$pkgver-py2
  python2 setup.py build
}

check() {
  cd "$srcdir"/isort-$pkgver
  python setup.py test

  cd "$srcdir"/isort-$pkgver-py2
  python2 setup.py test
}

package_python-isort() {
  depends=('python-setuptools')

  cd isort-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_python2-isort() {
  depends=('python2-setuptools' 'python2-futures')

  cd isort-$pkgver-py2
  python2 setup.py install --root="$pkgdir" --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  mv "$pkgdir"/usr/bin/isort{,2}
}
